home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form FrmScores
- BackColor = &H0000FF00&
- Caption = "-----Scores--------"
- ClientHeight = 4605
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 4320
- Icon = "FrmScores.frx":0000
- KeyPreview = -1 'True
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 307
- ScaleMode = 3 'Pixel
- ScaleWidth = 288
- StartUpPosition = 1 'CenterOwner
- Begin VB.TextBox TxtPlayerNameChange
- Alignment = 2 'Center
- Appearance = 0 'Flat
- BackColor = &H80000009&
- BorderStyle = 0 'None
- Enabled = 0 'False
- Height = 615
- Left = 1320
- MaxLength = 15
- TabIndex = 5
- TabStop = 0 'False
- Top = 2400
- Width = 1935
- End
- Begin VB.CommandButton CmdChangeName
- Caption = "&Change PlayerName"
- Height = 615
- Left = 0
- TabIndex = 3
- Tag = "SV"
- Top = 720
- Width = 1095
- End
- Begin VB.CommandButton CmdRndNumber
- Caption = "&Random Number"
- Height = 615
- Left = 0
- TabIndex = 4
- Tag = "SV"
- Top = 0
- Width = 1095
- End
- Begin VB.CommandButton CmdDisplayWinner
- Caption = "&Display Winner"
- Height = 615
- Left = 0
- TabIndex = 2
- Tag = "SV"
- Top = 1440
- Width = 1095
- End
- Begin VB.CommandButton CmdWriteFile
- Caption = "&Write File"
- Height = 615
- Left = 0
- TabIndex = 1
- Tag = "SV"
- Top = 2160
- Width = 1095
- End
- Begin VB.CommandButton CmdReadFile
- Caption = "R&ead File"
- Height = 615
- Left = 0
- TabIndex = 0
- Tag = "SV"
- Top = 2880
- Width = 1095
- End
- Begin VB.Label lblScore
- Alignment = 2 'Center
- Height = 615
- Index = 0
- Left = 3480
- TabIndex = 15
- Top = 0
- Width = 615
- End
- Begin VB.Label lblScore
- Alignment = 2 'Center
- Height = 615
- Index = 1
- Left = 3480
- TabIndex = 14
- Top = 600
- Width = 615
- End
- Begin VB.Label lblPlayer
- Alignment = 2 'Center
- Caption = "Player1"
- Height = 615
- Index = 0
- Left = 1320
- TabIndex = 13
- Top = 0
- Width = 1935
- End
- Begin VB.Label lblPlayer
- Alignment = 2 'Center
- Caption = "Player2"
- Height = 615
- Index = 1
- Left = 1320
- TabIndex = 12
- Top = 600
- Width = 1935
- End
- Begin VB.Label lblWinner
- Alignment = 2 'Center
- Height = 615
- Left = 1200
- TabIndex = 11
- Top = 3720
- Width = 2175
- End
- Begin VB.Label lblScore
- Alignment = 2 'Center
- Height = 615
- Index = 2
- Left = 3480
- TabIndex = 10
- Top = 1200
- Width = 615
- End
- Begin VB.Label lblScore
- Alignment = 2 'Center
- Height = 615
- Index = 3
- Left = 3480
- TabIndex = 9
- Top = 1800
- Width = 615
- End
- Begin VB.Label lblPlayer
- Alignment = 2 'Center
- Caption = "Player3"
- Height = 615
- Index = 2
- Left = 1320
- TabIndex = 8
- Top = 1200
- Width = 1935
- End
- Begin VB.Label lblPlayer
- Alignment = 2 'Center
- Caption = "Player4"
- Height = 615
- Index = 3
- Left = 1320
- TabIndex = 7
- Top = 1800
- Width = 1935
- End
- Begin VB.Label lblPrompt
- Alignment = 2 'Center
- Height = 615
- Left = 1320
- TabIndex = 6
- Top = 3000
- Width = 1935
- End
- Attribute VB_Name = "FrmScores"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- '----------FrmScores -------------------------
- 'score information in convenient block
- Private Sub Form_Load()
- Dim index As Integer 'to go through player array
- 'update labels
- For index = 0 To 3 '4 labels
- lblPlayer(index).Caption = players(index).name
- lblScore(index).Caption = players(index).score
- Next 'index
- End Sub 'form-load
- Private Sub TxtPlayerNameChange_KeyPress(KeyAscii As Integer)
- 'algorithm: if press return key and previously a number 1..4 was
- 'pressed then restore state of label focus of cmd button'change playername
- 'also turn labels and textinput off;
- 'else if we have a number 1..4 then calculate which player and
- 'redden his label and delete text input
- 'else if we've had a number-numberokay- then refresh label
- Dim index
- Static playertochange
- Static numberokay As Boolean
- If KeyAscii = 13 And numberokay Then
- lblPlayer(playertochange).BackColor = vbButtonFace
- lblPlayer(playertochange).ForeColor = &H80000012
- lblPlayer(playertochange).Caption = TxtPlayerNameChange.Text
- players(playertochange).name = TxtPlayerNameChange.Text
- '
- lblPrompt.Caption = ""
- numberokay = False
- CmdChangeName.SetFocus
- TxtPlayerNameChange.Text = ""
- TxtPlayerNameChange.Enabled = False
-
- Else
- If KeyAscii >= Asc("1") And KeyAscii <= Asc("4") And numberokay = False Then
- playertochange = KeyAscii - Asc("0") - 1 '49("1")-52("4")ascii changed to 0..3
- KeyAscii = 0 'throw away key
- lblPlayer(playertochange).BackColor = &H2995522
- lblPlayer(playertochange).ForeColor = &H2FFFFFF
- TxtPlayerNameChange.Text = ""
- lblPrompt.Caption = "Please Enter Player " & playertochange + 1
- numberokay = True
- Else
- If numberokay Then
- 'update label when input name
- lblPlayer(playertochange).Caption _
- = TxtPlayerNameChange.Text
-
- Else
- 'throw key away and exit back to cmdchangeplayername
- 'with focus
- KeyAscii = 0
- TxtPlayerNameChange.Text = ""
- CmdChangeName.SetFocus
- TxtPlayerNameChange.Enabled = False
- End If
- End If
- End If
- End Sub 'TxtPlayerNameChange-KeyPress
- Private Sub CmdReadFile_Click()
- Dim index, inname, inscore
- index = 0
- On Error GoTo out ' jump to out to avoid error of no disk or filer
- Open "A:\temp\playerdata" For Input As #1
- For index = 0 To 3
- Input #1, players(index).name, players(index).score
- lblPlayer(index).Caption = players(index).name
-
- lblScore(index).Caption = players(index).score
-
- Next
- Close #1
- End Sub 'CmdReadFile
- Private Sub CmdWriteFile_Click()
- Dim index
- On Error GoTo out ' jump to out to avoid error of no disk or filer
- Open "A:\temp\playerdata" For Output As #1
- For index = 0 To 3
- Write #1, players(index).name
- Write #1, players(index).score
- Next
- Close #1
- End Sub 'CmdWriteFile
- Private Sub CmdChangeName_Click()
- 'change players names
- TxtPlayerNameChange.Enabled = True
- 'prompt on testbox
- TxtPlayerNameChange.Text = " Which Player? 1..4"
- TxtPlayerNameChange.SetFocus
- End Sub 'CmdChangeName
- Private Sub CmdQuit_Click()
- End Sub
- Private Sub CmdRndNumber_Click()
- Dim index
- 'generate random number for each players score
- 'save in field players().score
- For index = 0 To 3
- players(index).score = Int(Rnd * 100 + 1)
- 'update lables
- lblPlayer(index).Caption = players(index).name
- lblScore(index).Caption = players(index).score
-
- Next
- End Sub 'CmdRndNumber-click
- Private Sub CmdDisplayWinner_Click()
- 'compare scores of players
- Dim temp, x, winnerindex
- temp = players(0).score
- winnerindex = 0
- For x = 0 To 3
- If temp < players(x).score Then
- temp = players(x).score
- winnerindex = x
- End If
- Next
- 'output result
- 'what about 2 equal scores? not implemented yet
- lblWinner.Caption = "Winner = " & players(winnerindex).name + Chr$(13) & "Score= " & players(winnerindex).score
- End Sub 'CmdDisplayWinner-click
- Private Sub Form_Unload(Cancel As Integer)
- 'turn back on timers
- With FrmGameScreen
- .TmrClock.Enabled = True
- .TmrEnergy1.Enabled = True
- .TmrMoveAliens.Enabled = True
- .TmrPlayerMissile.Enabled = True
- End With
- End Sub 'form-unload
-